Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald-tests\uint8-tests.cpp
Line
Count
Source (jump to first uncovered line)
1
//  Copyright 2021 Herald Project Contributors
2
//  SPDX-License-Identifier: Apache-2.0
3
//
4
5
#include <iostream>
6
#include <fstream>
7
#include <string>
8
9
#include "catch.hpp"
10
11
#include "herald/herald.h"
12
13
#include "test-util.h"
14
15
0
TEST_CASE("crossplatform-uint8", "[.][uint8][crossplatform]") {
16
0
  SECTION("crossplatform-uint8") {
17
0
    // Check output file can be created
18
0
    auto fn = testutil::fullFilename("uint8.csv");
19
0
    INFO("Output filename: " << fn);
20
0
    std::ofstream cppOut(fn);
21
0
    cppOut << "value,data" << std::endl;
22
0
    std::uint8_t result;
23
0
    for (std::uint8_t i = std::numeric_limits<uint8_t>::min(); i < std::numeric_limits<uint8_t>::max(); ++i) {
24
0
      herald::datatype::Data data;
25
0
      data.append(i);
26
0
      // REQUIRE(data.uint8(0,result));
27
0
      // REQUIRE(i == result);
28
0
      cppOut << (unsigned int)i << "," << herald::datatype::Base64String::encode(data).encoded() << std::endl;
29
0
    }
30
0
    // now generate last value too (doing it in the loop results in an infinite loop in C++!)
31
0
    std::uint8_t i = std::numeric_limits<uint8_t>::max();
32
0
    herald::datatype::Data data;
33
0
    data.append(i);
34
0
    // REQUIRE(data.uint8(0,result));
35
0
    // REQUIRE(i == result);
36
0
    cppOut << (unsigned int)i << "," << herald::datatype::Base64String::encode(data).encoded() << std::endl;
37
0
38
0
    cppOut.close();
39
0
40
0
    // Now ensure our output matches the other platforms'
41
0
    testutil::validateEqual("uint8.csv");
42
0
  }
43
0
}